#ifndef MODULEHPLCPUMP_H
#define MODULEHPLCPUMP_H

#include <QTimer>
#include "basemodule.h"
#include "port/baseport.h"
#include "base/baseprotocol.h"
#include "modulehplcpumpdefine.h"

class ModuleHplcPump : public BaseModule
{
    Q_OBJECT
public:
    ModuleHplcPump(QObject *parent = nullptr);
    virtual ~ModuleHplcPump() override;

    virtual bool setConfig(int id, QVariant &var) override;
    virtual bool getConfig(int id, QVariant &var) override;

    virtual bool setParam(int id, QVariant &var) override;
    virtual bool getParam(int id, QVariant &var) override;

    bool setProtocolCmd(int id, QVariant &var);
    bool getProtocolCmd(int id, QVariant &var);

    void setPort(BasePort *port);
    BasePort *getPort(void);
    void setProtocol(BaseProtocol *protocol);
    BaseProtocol *getProtocol(void);

    void setProtocolAddress(quint8 address);
    quint8 getProtocolAddress(void);

    hplc::PumpParam *getParam();

signals:
    void requestSend(const QByteArray &ba);
    void parseCompleted(int id, const QVariant &data);

public slots:
    void onTimeout();
    void onParse(QList<ProtocolPacket> packets);
    virtual void onStart() override;

private:
    BasePort                *m_port = nullptr;
    BaseProtocol            *m_protocol = nullptr;

    QTimer                  *m_timer = nullptr;

    hplc::PumpParam			m_param;
};

#endif // MODULEHPLCPUMP_H
